package com.cn.lp.ai.factory;

import com.fasterxml.jackson.annotation.JsonClassDescription;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import org.springframework.context.annotation.Description;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.function.Function;

@Component
@Description("先获取指定地点,再获取当前时间")
public class DateService implements Function<DateService.Request, DateService.Response> {

    @JsonClassDescription("地点请求")
    public record Request(@JsonPropertyDescription("地点")String address) { }

    public record Response(String date) { }

    @Override
    public Response apply(Request request) {
        System.out.println(request.address);
        return new Response(String.format("%s的当前时间是%s", request.address, LocalDateTime.now()));
    }
}